package com.swagger2.web;

import com.swagger2.entity.MyUser;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author: LCG
 * 作者: LCG
 * 日期: 2021/6/29  15:14
 * 描述:
 */
@RestController
@Api(description = "详细的描述接口类似是干什么的")
@RequestMapping("v01")
public class TestController01 {

    @RequestMapping("getUserById")
    @ApiOperation(value = "getUserById--value",tags={"getUserById1"},notes = "根据UserId获取一个User实例",response=MyUser.class)
    @ApiResponses(
            value={
                    @ApiResponse(code=200,message = "请求成功"),
                    @ApiResponse(code=500,message = "服务器端出错")
            }
    )
    @ApiImplicitParams(
            value = {
                  @ApiImplicitParam(dataType = "Map",name = "map",required = true,defaultValue = "{\"userName\":\"张三\"}",paramType ="body",example = "{\"userName\":\"张三\"}")
            }
    )
    public MyUser getUserById(@RequestBody Map<String,Object> map){


        System.out.println("=====请求参数======>"+map);

        MyUser myUser = new MyUser();

        myUser.setUserName(map.get("userName").toString());

        return myUser;
    }



    @RequestMapping("getUserList")
    @ApiOperation(value = "getUserList--value",tags={"getUserList-tags"},notes = "获取一个user列表",response=Object.class)
    @ApiResponses(
            value={
                    @ApiResponse(code=200,message = "请求成功"),
                    @ApiResponse(code=500,message = "服务器端出错")
            }
    )
    @ApiImplicitParams(
            value = {
                    @ApiImplicitParam(dataType = "MyUser",name = "myUser",required = true,paramType ="body")
            }
    )
    public Object getUserList(@RequestBody MyUser myUser){


        System.out.println("=====请求参数======>"+myUser);



        return myUser.getListUser();
    }

}
